package com.wlz.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 路由模式|Routing模式   交换机类型：direct
 * @author wlz
 * @date 2022-06-29  10:03 下午
 */
@Configuration
public class DirectConfig {

    /**
     *  声明队列
     * @return
     */
    @Bean
    public Queue directQueue1() {
        return new Queue("wlz_direct_queue_1");
    }

    @Bean
    public Queue directQueue2() {
        return new Queue("wlz_direct_queue_2");
    }


    /**
     *  声明 exchange
     * @return
     */
    @Bean
    public DirectExchange setDirectExchange() {
        return new DirectExchange("wlz_direct_exchange");
    }


    /**
     *  声明 binding , 需要声明 一个 routingkey
     * @return
     */
    @Bean
    public Binding bindDirectBind1() {
        return BindingBuilder.bind(directQueue1()).to(setDirectExchange()).with("wlz.aaa");
    }

    /**
     *  声明 binding , 需要声明 一个 routingkey
     * @return
     */
    @Bean
    public Binding bindDirectBind2() {
        return BindingBuilder.bind(directQueue2()).to(setDirectExchange()).with("wlz.bbb");
    }

}
